﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AxlfVSX.Core;
using Microsoft.VisualStudio.Shell;
using EnvDTE;

namespace Aoxuelf.MDSTool.Commands
{
    public class DynamicCommand : MenuCommandHandler
    {
        private DTE dte;
        protected DynamicCommand(Package package)
            : base(package)
        {
        }

        protected DTE Dte
        {
            get
            {
                if (this.dte == null)
                {
                    this.dte = (DTE)this.ServiceProvider.GetService(typeof(DTE));
                }

                return this.dte;
            }
        }

        protected override void OnQueryStatus(OleMenuCommand command)
        {
            command.Enabled = command.Visible = CanExecute(command);
        }

        protected virtual bool CanExecute(OleMenuCommand command)
        {
            return true;
        }
    }
}
